package com.project.service.impl;


import com.project.bean.InfoBean;
import com.project.bean.MQBean;
import com.project.bean.ShopBean;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RabbitService {
    @Autowired
    RabbitTemplate rabbitTemplate;

    RabbitTemplate.ConfirmCallback callback=(CorrelationData correlationData, boolean b, String s)->{

    };
    //默认
        public void  sendUser(InfoBean infoBean){
        //开启手动确认
        rabbitTemplate.setMandatory(true);//开启消息确认
        //绑定回调函数
        rabbitTemplate.setConfirmCallback(callback);
        //创建关联数据对象
        CorrelationData correlationData=new CorrelationData(infoBean.getOrderNum());

        rabbitTemplate.convertAndSend("directExchangeInfo","info.k",infoBean,correlationData);
    }

}
